// pages/service/service.js
const api = require('../../../app/app.js')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    IMG_URL: 'https://www.sdhjfu.com/tooltwo/public/admin/',
    serviceInfo: {},
    mort: '../../../images/f3.jpg',
    wxText: '15192800023',
    search: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/service_search.jpg',
    logo: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/logo.jpg',
    tel_img: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/service_phone.jpg',
    service_mess: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/service_mess.jpg',
    service_wx: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/service_wx.jpg',
    service_tel: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/service_tel.jpg'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  getMoneyATab(e) {
    let rate = e.detail.value;
    this.setData({
      bu: rate
    })
  },
  // 点击跳转到搜索页面
  searchClick () {
    wx.navigateTo({
      url: '../components/search/search'
    })
  },
  // 点击跳转到贷款计算器
  calculator() {
    wx.navigateTo({
      url: '../components/mortgage/calculator/calculator'
    })
  },
  // 点击跳转到房产政策解读
  policy() {
    wx.navigateTo({
      url: '../components/policy/policy'
    })
  },
  // 点击跳转到房产估价
  evaluation() {
    wx.navigateTo({
      url: '../components/evaluations/evaluations'
    })
  },
  // 点击跳转到购房资质
  qualifications() {
    wx.navigateTo({
      url: '../components/qualifications/qualifications'
    })
  },
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '服务'
    })
    wx.showLoading({ // 加载数据前的loading
      title: '加载中'
    })
    var that = this
    var houseid = wx.getStorageSync('houseid') // 同步获取存储
    // console.log(houseid)
    wx.request({
      url: api.Service,
      method: 'POST',
      data: {
        houseid: houseid
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        // console.log(res.data)
        that.setData({
          serviceInfo: res.data
        })
        wx.hideLoading() // 数据调出后关闭loading
      }
    })
  },
  // 复制微信号
  wxClick: function (e) {
　　wx.setClipboardData({
　　　data: e.currentTarget.dataset.text,
　　　success: function (res) {
　　　wx.getClipboardData({
  　　　success: function (res) {
    　　　wx.showToast({
      　　　title: '复制成功'
    　　　})
  　　　}
　　　})
　　}
　})
},
  // 拨打电话
  telClick: function(e) {
    var ind = e.currentTarget.id
    var phone = this.data.serviceInfo.adviserre[ind].adviser_iphone
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
  mortgage: function() {
    wx.navigateTo({
      url: '../components/mortgage/calculator/calculator',
    })
  },
  // 点击头像放大
  headPhoto: function(e) {
    var ind = e.currentTarget.id
    console.log(ind)
    var headPhoto = this.data.IMG_URL + this.data.serviceInfo.adviserre[ind].adviser_headimge
    var imgArr = [];
    imgArr[0] = headPhoto
    wx.previewImage({
      current: headPhoto, // 当前显示图片的http链接
      urls: imgArr // 需要预览的图片http链接列表
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})
